package study;

public class singleton1 {
    //在单例子类的内部创建一个自己本身的对象
    private static singleton1 instance;

    //构造器的私有化
    private singleton1() {

    }

    public static singleton1 getInstance() {
        if (instance == null){
            instance = new singleton1();
        }
        return instance;
    }

}

/**
 * 测试代码
 */
class TestSingle1 {
    public static void main(String[] args) {
        singleton1 s = singleton1.getInstance();
        singleton1 s1 = singleton1.getInstance();
//        singletom s2 = singletom.getInstance();
//        singletom s3 = singletom.getInstance();
        System.out.println(s);
        System.out.println(s1);
//        System.out.println(s2);
//        System.out.println(s3);
    }
}